<!--
 * @Author: sunkaiyuan sunkaiyuan@namenode.com
 * @Date: 2022-10-05 22:47:33
 * @LastEditors: sunkaiyuan sunkaiyuan@namenode.com
 * @LastEditTime: 2023-02-01 09:24:07
 * @Description: 
-->
<template>
  <el-container style="height: 100%">
    <el-aside width="200px">
      <sk-category :url="$API.system.menu" @select="categoryselect" :editable="false" :showfield="'meta.title'">
      </sk-category>
    </el-aside>
    <el-main style="height: 100%">
      <sc-VxeTable ref="xGrid1" :gridEvts="gridEvents" :tablecode="'setting_tableconfig_index'" :url="apiObj">
      </sc-VxeTable>
    </el-main>
  </el-container>
  <save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSuccess" @closed="dialog.save = false"></save-dialog>
</template>

<script>
import skCategory from "@/components/skCategory";
import saveDialog from "./save";

export default {
  name: "tableConfigSetting",
  components: {
    skCategory,
    saveDialog,
  },
  data() {
    return {
      dialog: {
        save: false,
      },
      apiObj: this.$API.system.tableconfig.list,
      selection: [],
      gridEvents: {
        add: () => {
          this.add();
        },
        edit: (param) => {
          this.table_edit(param.$grid.getCheckboxRecords()[0]);
        },
        cellDblclick: ({ row }) => {
          this.table_edit(row);
        },
        table_copy: (param) => {
          this.table_copy(param.$grid.getCheckboxRecords()[0]);
        },
      },
    };
  },
  mounted() { },
  methods: {
    //增加
    add() {
      this.dialog.save = true;
      this.$nextTick(() => {
        this.$refs.saveDialog.open();
      });
    },
    //编辑
    table_edit(row) {
      this.dialog.save = true;
      this.$nextTick(() => {
        this.$refs.saveDialog.open("edit").setData(row);
      });
    },
    table_copy(row) {
      this.dialog.save = true;
      this.$nextTick(() => {
        this.$refs.saveDialog.open("copy").setData(row);
      });
    },
    categoryselect: function (data, ids) {
      this.$refs.xGrid1.search("category_id", ids, "in");
      this.handleSuccess();
    },

    //本地更新数据
    handleSuccess() {
      this.$refs.xGrid1.refresh();
    },
  },
};
</script>
<style></style>
